home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / v3_1 / sbp3_1e.lzh / AGREEMNT.PL next >
Text File  |  1991-10-31  |  1KB  |  35 lines

  1. /* From the book PROLOG PROGRAMMING IN DEPTH
  2.    by Michael A. Covington, Donald Nute, and Andre Vellino.
  3.    Copyright 1988 Scott, Foresman & Co.
  4.    Non-commercial distribution of this file is permitted. */
  5. /* Modified for Quintus Prolog by Andreas Siebert */
  6.  
  7. /* AGREEMNT.PL */
  8.  
  9. /* Parser for sentences with
  10.    verb-subject number agreement. */
  11.  
  12. /* Queries will use the built-in predicate phrase/2 */
  13.  
  14. /* The argument N is the number of
  15.    the subject and main verb.
  16.    It is instantiated to 'singular'
  17.    or 'plural' as the parse progresses. */
  18.  
  19. sentence --> noun_phrase(N), verb_phrase(N).
  20.  
  21. noun_phrase(N) --> determiner(N), noun(N).
  22.  
  23. verb_phrase(N) --> verb(N), noun_phrase(_).
  24. verb_phrase(N) --> verb(N), sentence.
  25.  
  26. determiner(singular) --> [a].
  27. determiner(_)        --> [the].
  28. determiner(plural)   --> [].
  29.  
  30. noun(singular) --> [dog];[cat];[boy];[girl].
  31. noun(plural)   --> [dogs];[cats];[boys];[girls].
  32.  
  33. verb(singular) --> [chases];[sees];[says];[believes].
  34. verb(plural)   --> [chase];[see];[say];[believe].
  35.